<!-- 从业者端-在线学习-模拟考试成绩页-->
<template>
  <view class="container">
    <!-- 成绩展示区 -->
		<view class="container-head">
			<view class="score-section" v-if="isExce == 'kaoshi'">
			  <text class="score">{{ score }}</text>
			  <text class="score-label">考试成绩（分）</text>
			</view>
			
			<!-- 统计数据 -->
			<view class="stats-grid">
			  <view class="stat-item">
			    <text class="stat-value">{{ timeUsed }}</text>
			    <text class="stat-label">用时</text>
			  </view>
			  <view class="stat-item">
			    <text class="stat-value">{{ wrongCount }}</text>
			    <text class="stat-label">错题</text>
			  </view>
				<view class="stat-item">
				  <text class="stat-value">{{ correctCount }}</text>
				  <text class="stat-label">正确</text>
				</view>
				<view class="stat-item">
				  <text class="stat-value">{{ correctRate }}%</text>
				  <text class="stat-label">正确率</text>
				</view>
			</view>
		</view>    
    
    <!-- 操作按钮 -->
    <view class="action-buttons">
      <u-button class="action-btn" type="default" shape="circle" @click="goBack" :customStyle="customStylePay">返回</u-button>
      <u-button v-if="isExce == 'kaoshi'" class="action-btn" type="primary" shape="circle" @click="viewAnalysis" :customStyle="customStylePay">错题解析</u-button>
      <!-- <u-button v-else class="action-btn" type="primary" shape="circle" @click="viewExceics" :customStyle="customStylePay">练习记录</u-button> -->
		</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
			customStylePlan: {
				"color": "#03B8CD"
			},
			customStylePay: {
				"backgroundColor": "#03B8CD",
				"color": "#ffffff"
			},
      score: 0,       // 考试成绩
      timeUsed: '00:00', // 用时
      wrongCount: 5     ,// 错题数
			correctCount: 0, //、正确数
			exceCount: 0,  ////总题目数
			correctRate: 0, ////正确率
			isExce:'kaoshi',
			btTaskCode: '' ,///练习任务编号
			doQuestionAnswer:[],///存储题目答题
    }
  },
	onLoad(options) {
		this.isExce = options.isExce
		this.btTaskCode = options.btTaskCode
	},
	onShow() {
		this.getBtmDetails()
	},
  methods: {
		// 查询题库下题目的复制列表
		// 对的答案标识是1，错误是2
		getBtmDetails() {
			// this.$u.api.querytktmlist({
			// 	"cyctkcode": this.btTaskCode,
			// }).then(res => {
			// 	this.doQuestionAnswer = res.data.base_info
			// 	this.exceCount = this.doQuestionAnswer.length
			// 	let notDo = this.doQuestionAnswer.filter(item => item.cyctkd_isright == 0 ).length
			// 	this.wrongCount = this.doQuestionAnswer.filter(item => item.cyctkd_isright == 2 ).length+notDo
			// 	this.correctCount = this.doQuestionAnswer.filter(item => item.cyctkd_isright == 1 ).length
			// 	this.correctRate = (this.correctCount/this.exceCount)*100
			// 	this.score = this.correctCount
			// 	console.log('复制：', res, this.exceCount,)
			// })
			this.$u.api.quyerybctkresult({
				"cyctkcode": this.btTaskCode
			}).then(res => {
				let baseinfo = res.data.base_info
				let notDo = baseinfo.nodo
				this.wrongCount = baseinfo.iswrong+notDo
				this.correctCount = baseinfo.isright
				this.correctRate = (this.correctCount/baseinfo.tol)*100
				this.score = this.correctCount
				this.timeUsed = baseinfo.usetime
				console.log('成绩：', res)
			}).catch(err => {

			})
		},
		
    // 返回上一页
    goBack() {
      uni.navigateTo({
        url: '/pages/Practitioner/question/question'
      })
    },
    // 查看错题解析
    viewAnalysis() {
      uni.navigateTo({
        url: '/pages/Practitioner/question/simulationMistakes'
      })
    },
		viewExceics() {
			uni.navigateTo({
			  url: '/pages/Practitioner/studyManage/studyRecord'
			})
		}
  }
}
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  // justify-content: center;
  height: 100vh;
  background-color: #F1F7F7;
  padding: 40rpx;
}

.container-head {
	 background-color: #ffffff;
	 border-radius: 10px;
	 width: 100%;
	 padding: 10px;
	 margin: 10px 10px 50px 10px;
}

.score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 60rpx;
  
  .score {
    font-size: 100rpx;
    font-weight: bold;
    color: #03B8CD;
    margin-bottom: 10rpx;
  }
  
  .score-label {
    font-size: 28rpx;
    color: #666;
  }
}

.stats-grid {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-bottom: 60rpx;
	margin-top: 60rpx;
  
  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    
    .stat-value {
      font-size: 48rpx;
      font-weight: bold;
      color: #333;
      margin-bottom: 10rpx;
    }
    
    .stat-label {
      font-size: 26rpx;
      color: #666;
    }
  }
}

.action-buttons {
  width: 100%;
  display: flex;
  justify-content: space-between;
	
  
  .action-btn {
    width: 90%;
		margin-right: 10rpx;
		margin: auto;
    
    /deep/ .u-btn {
      height: 90rpx;
      font-size: 32rpx;
    }
  }
}
</style>